package com.sky.mapper;

import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    //根据菜品Id查询套餐Id
    List<Long> getSetmealIdbyDishId(List<Long> dishids);

    //新增菜品与套餐关系表
    void insert(List<SetmealDish> setmealDishes);

    //根据套餐ids批量删除套餐与菜品关系表
    void delate(List<Long> setmealIds);

    @Select(("select * from sky_take_out.setmeal_dish where setmeal_id = #{setmealId}"))
    List<SetmealDish> getBySetmealId(Long setmealId);

    //根据套餐id删除套餐与菜品关系
    @Delete("delete from sky_take_out.setmeal_dish where setmeal_id = #{setmealId}")
    void delateBySetmealId(Long setmealId);

    //根据套餐id查询菜品
    @Select("select a.* from sky_take_out.dish a left join sky_take_out.setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getDishBySetmealId(Long id);
}
